home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / switchPanes.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.3 KB  |  291 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date: 
  22. //  Author:         
  23. //
  24.  
  25. global proc switchPanes (string $doWhat, int $usePointer)
  26. {
  27.     global string        $gMainPane;
  28.     global int            $gPoppedPane = -1;
  29.     global string        $gPrePopConfig;
  30.     global string        $gPrePopControls[4];
  31.     global int            $gPrePopSizes[8];
  32.       string                $currPane;
  33.     
  34.     if ($gMainPane != "" && `paneLayout -exists $gMainPane`) {
  35.         if ($doWhat == "goBack") {
  36.             if (`panelHistory -q -isEmpty mainPanelHistory`) {
  37.                 //
  38.                 //  No history so go to four view, but make sure current
  39.                 //  camera is preserved.
  40.                 //
  41.                 string $currCam = "";
  42.                 string $currPanel = `getPanel -withFocus`;
  43.                 if ("modelPanel" == `getPanel -typeOf $currPanel`) {
  44.                     //
  45.                     // save the camera
  46.                     //
  47.                     $currCam = `modelPanel -q -cam $currPanel`;
  48.                 }
  49.  
  50.                 string $config = `getPanel -cwl "Four View"`;
  51.                 if ("" != $config) {
  52.                     setNamedPanelLayout "Four View";
  53.                 } else {
  54.                     panelHistory -e -suspend on mainPanelHistory;
  55.                     paneLayout -e -cn "quad"  $gMainPane;
  56.                     fillEmptyPanes;
  57.                     panelHistory -e -suspend off mainPanelHistory;
  58.                 }
  59.  
  60.                 //
  61.                 //  Make sure the previous camera view is represented
  62.                 //
  63.                 if ($currCam != "" && $currCam != "persp" && $currCam != "top" &&
  64.                     $currCam != "front" && $currCam != "side") 
  65.                 {
  66.                     //
  67.                     //  put camera in persp view
  68.                     //
  69.                     string $perspPanel = `getPanel -withLabel "Persp View"`;
  70.                     if (`modelPanel -exists $perspPanel`) {
  71.                         modelPanel -e -cam $currCam $perspPanel;
  72.                     }
  73.                 }
  74.             } else {
  75.                 if ($gPoppedPane > 0) {
  76.                     //
  77.                     //  Restore pre popped config
  78.                     //
  79.                     panelHistory -e -suspend on mainPanelHistory;
  80.  
  81.                     $currPane = `paneLayout -q -p1 $gMainPane`;
  82.                     paneLayout -e -manage false $gMainPane;
  83.                     paneLayout -e -cn $gPrePopConfig $gMainPane;
  84.  
  85.                     int $nArr = size($gPrePopSizes);
  86.                     if (`panel -exists $gPrePopControls[0]` &&
  87.                         !`panel -q -to $gPrePopControls[0]`
  88.                        ) 
  89.                     {
  90.                         if ("" == `panel -q -control $gPrePopControls[0]`) {
  91.                             // 
  92.                             // parent the panel to the main pane first.
  93.                             //
  94.                             string $pType = `getPanel -typeOf $gPrePopControls[0]`;
  95.                             string $cmd = ($pType +" -e -parent $gMainPane "+
  96.                                            $gPrePopControls[0]);
  97.                             eval $cmd;
  98.                         }
  99.                             
  100.                         paneLayout -e 
  101.                             -sp $gPrePopControls[0] 1
  102.                             -ps 1 $gPrePopSizes[0] $gPrePopSizes[1]
  103.                             $gMainPane;
  104.                     } else {
  105.                         $gPrePopControls[0] = "";
  106.                     }
  107.  
  108.                     if ($nArr > 3 && `panel -exists $gPrePopControls[1]` && 
  109.                         !`panel -q -to $gPrePopControls[1]`
  110.                        ) 
  111.                     {
  112.                         if ("" == `panel -q -control $gPrePopControls[1]`) {
  113.                             // 
  114.                             // parent the panel to the main pane first.
  115.                             //
  116.                             string $pType = `getPanel -typeOf $gPrePopControls[1]`;
  117.                             string $cmd = ($pType +" -e -parent $gMainPane "+
  118.                                            $gPrePopControls[1]);
  119.                             eval $cmd;
  120.                         }
  121.                             
  122.                         paneLayout -e 
  123.                             -sp $gPrePopControls[1] 2
  124.                             -ps 2 $gPrePopSizes[2] $gPrePopSizes[3]
  125.                             $gMainPane;
  126.                     } else {
  127.                         $gPrePopControls[1] = "";
  128.                     }
  129.  
  130.                     if ($nArr > 5 && `panel -exists $gPrePopControls[2]` &&
  131.                         !`panel -q -to $gPrePopControls[2]`
  132.                        ) 
  133.                     {
  134.                         if ("" == `panel -q -control $gPrePopControls[2]`) {
  135.                             // 
  136.                             // parent the panel to the main pane first.
  137.                             //
  138.                             string $pType = `getPanel -typeOf $gPrePopControls[2]`;
  139.                             string $cmd = ($pType +" -e -parent $gMainPane "+
  140.                                            $gPrePopControls[2]);
  141.                             eval $cmd;
  142.                         }
  143.                             
  144.                         paneLayout -e 
  145.                             -sp $gPrePopControls[2] 3
  146.                             -ps 3 $gPrePopSizes[4] $gPrePopSizes[5]
  147.                             $gMainPane;
  148.                     } else {
  149.                         $gPrePopControls[2] = "";
  150.                     }
  151.  
  152.                     if ($nArr > 7 && `panel -exists $gPrePopControls[3]` &&
  153.                         !`panel -q -to $gPrePopControls[3]`
  154.                        ) 
  155.                     {
  156.                         if ("" == `panel -q -control $gPrePopControls[3]`) {
  157.                             // 
  158.                             // parent the panel to the main pane first.
  159.                             //
  160.                             string $pType = `getPanel -typeOf $gPrePopControls[3]`;
  161.                             string $cmd = ($pType +" -e -parent $gMainPane "+
  162.                                            $gPrePopControls[3]);
  163.                             eval $cmd;
  164.                         }
  165.                             
  166.                         paneLayout -e 
  167.                             -sp $gPrePopControls[3] 4
  168.                             -ps 4 $gPrePopSizes[6] $gPrePopSizes[7]
  169.                             $gMainPane;
  170.                     } else {
  171.                         $gPrePopControls[3] = "";
  172.                     }
  173.                     
  174.  
  175.                     //
  176.                     //  preserve current panel by placing it in the
  177.                     //  popped pane.  If current panel existed elsewhere
  178.                     //  in the config then compensate.
  179.                     //
  180.                     int $swapped = -1;
  181.                     if ($currPane == $gPrePopControls[0]) {
  182.                         if ($gPoppedPane != 1) {
  183.                             paneLayout -e 
  184.                                 -sp $currPane $gPoppedPane
  185.                                 $gMainPane;
  186.                             $swapped = 1;
  187.                         }
  188.                     } else if ($currPane == $gPrePopControls[1]) {
  189.                         if ($gPoppedPane != 2) {
  190.                             paneLayout -e 
  191.                                 -sp $currPane $gPoppedPane
  192.                                 $gMainPane;
  193.                             $swapped = 2;
  194.                         }
  195.                     } else if ($currPane == $gPrePopControls[2]) {
  196.                         if ($gPoppedPane != 3) {
  197.                             paneLayout -e 
  198.                                 -sp $currPane $gPoppedPane
  199.                                 $gMainPane;
  200.                             $swapped = 3;
  201.                         }
  202.                     } else if ($currPane == $gPrePopControls[3]) {
  203.                         if ($gPoppedPane != 4) {
  204.                             paneLayout -e 
  205.                                 -sp $currPane $gPoppedPane
  206.                                 $gMainPane;
  207.                             $swapped = 4;
  208.                         }
  209.                     } else {
  210.                         paneLayout -e 
  211.                             -sp $currPane $gPoppedPane
  212.                             $gMainPane;
  213.                     }
  214.  
  215.                     if (0 < $swapped) {
  216.                         //
  217.                         //  A pre-popped control has been swapped into the popped 
  218.                         //  pane.  Try to swap positions if it is still a child.
  219.                         //
  220.                         string $childs[] = `paneLayout -q -ca $gMainPane`;
  221.                         for ($child in $childs) {
  222.                             if ($gPrePopControls[$gPoppedPane-1] == $child) {
  223.                                 paneLayout -e 
  224.                                     -sp $child $swapped
  225.                                     $gMainPane;
  226.                             }
  227.                         }
  228.                     }
  229.  
  230.                     fillEmptyPanes;
  231.  
  232.                     paneLayout -e -manage true $gMainPane;
  233.                     setFocus $currPane;
  234.  
  235.                     panelHistory -e -suspend off mainPanelHistory;
  236.                 } else {
  237.                     panelHistory -e -back mainPanelHistory;
  238.                 }
  239.             }
  240.         } else {
  241.             panelHistory -e -suspend on mainPanelHistory;
  242.  
  243.             if ($usePointer == 1) {
  244.                 $currPane = `paneLayout -q -pup $gMainPane`;
  245.                 if ("single" == $doWhat) {
  246.                     //
  247.                     //  save pane state for popping.
  248.                     //
  249.                     $gPrePopControls[0] = `paneLayout -q -p1 $gMainPane`;
  250.                     $gPrePopControls[1] = `paneLayout -q -p2 $gMainPane`;
  251.                     $gPrePopControls[2] = `paneLayout -q -p3 $gMainPane`;
  252.                     $gPrePopControls[3] = `paneLayout -q -p4 $gMainPane`;
  253.  
  254.                     if ($gPrePopControls[0]  == $currPane) {
  255.                         $gPoppedPane = 1;
  256.                     } else if ($gPrePopControls[1]  == $currPane) {
  257.                         $gPoppedPane = 2;
  258.                     } else if ($gPrePopControls[2]  == $currPane) {
  259.                         $gPoppedPane = 3;
  260.                     } else if ($gPrePopControls[3]  == $currPane) {
  261.                         $gPoppedPane = 4;
  262.                     } else {
  263.                         $gPoppedPane = 1;
  264.                     }
  265.  
  266.                     $gPrePopSizes = `paneLayout -q -ps $gMainPane`;
  267.                     $gPrePopConfig = `paneLayout -q -cn $gMainPane`;
  268.                 }
  269.             } else {
  270.                 $currPane = `getPanel -withFocus`;
  271.             }
  272.             
  273.             // If there is no current panel then don't try to
  274.             // switch to it.
  275.             //
  276.             if ($currPane != "") {
  277.                 paneLayout -e -cn $doWhat $gMainPane;
  278.                 if ($doWhat == "single") {
  279.                     paneLayout -e -setPane $currPane 1 $gMainPane;
  280.                 }
  281.                 setFocus `paneLayout -q -p1 $gMainPane`;
  282.  
  283.                 fillEmptyPanes;
  284.  
  285.             }
  286.             
  287.             panelHistory -e -suspend off mainPanelHistory;
  288.         }
  289.     }
  290. }
  291.